
<?php
//<=============================Bean developpé par BOUFTIH FADWA >======================//
include_once('beans/planningBean.php');
//include_once("verif_session.php");
include("bdd_connection.php");
include_once('config.php');
include_once('ConnectBD.php');

class planningDao{
	public $listePlanning=array();
  public function loadAllTachePlannifiee(){
     $req=connexion()->prepare("select * from tacheplannifiee tp,tache t,nomade_tache nt where tp.id_tache=t.idTache and nt.idTache=t.idTache");
     $req->execute();

     while($row = $req->fetch(PDO::FETCH_OBJ)) {
       $planning=new planningBean();
       $planning->setIdTachePlanifier(utf8_encode($row->idTachePlanifier));
       $planning->setIdTache(utf8_encode($row->idTache));
       $planning->setObjectif(utf8_encode($row->objectif));
       $planning->setDesignation(utf8_encode($row->designation));
       $planning->setDateDebut(utf8_encode($row->dateDebut));
       $planning->setOrdrePriorite(utf8_encode($row->ordrePriorite));
       $planning->setDateFin(utf8_encode($row->dateFin));
       $planning->setIdNomade(utf8_encode($row->idNomade));
       $listePlanning[]=$planning;
       }
       return $listePlanning;
   }

   public function insertPlanning($planning){
      $idtache=$planning->getIdTache();
      $ordrePriorite =$planning->getOrdrePriorite();
      //$idAdmin=$planning->getIdAdministrateur();
      $dateFin=$planning->getDateFin();
      $requete_insert=connexion()->exec("INSERT INTO tacheplannifiee VALUES('',$ordrePriorite,$idtache,10,'$dateFin')");
    }

    public function deletePlanning($planning){   //supression d'un planning avec idtacheplannifier
      $idtp=$planning->getIdTachePlanifier();
      $requete_insert=connexion()->exec("delete from tacheplannifiee where idTachePlannifier=$idtp");

    }
}

?>
